package TestModel;

import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.LinkedList;

import DataModel.CommonLibrary.CommonDefs.Layer;
import DataModel.LayoutManager.CRectangle;
import DataModel.LayoutParser.CIFExporter;
import DataModel.LayoutParser.CIFImporter;

import junit.framework.TestCase;

public class CIFImportExportTest extends TestCase {

	// C'tor
	public CIFImportExportTest()
	{
		m_recsList = new LinkedList<CRectangle>();
		
		File file = new File("demo/autoTest.cif");		
		URL fileURL = null;
		try {
			fileURL = file.getAbsoluteFile().toURI().toURL();
		} catch (MalformedURLException e){
			e.printStackTrace();
		}
		
		m_recsList.add(new CRectangle(22000,-18000,28000,16000,Layer.Metal1,0));
		m_recsList.add(new CRectangle(11000,1000,28000,3500,Layer.Metal1,1));
		m_recsList.add(new CRectangle(11000,1000,14000,11000,Layer.Metal1,2));
		m_recsList.add(new CRectangle(12000,-12000,26000,-10000,Layer.Metal1,3));
		m_recsList.add(new CRectangle(-25000,-20000,-21000,20000,Layer.Metal1,4));
		m_recsList.add(new CRectangle(-24000,1000,-10000,3000,Layer.Metal1,5));
		m_recsList.add(new CRectangle(-12000,1000,-10000,11000,Layer.Metal1,6));
		m_recsList.add(new CRectangle(-14000,-11000,-3000,-10000,Layer.Metal1,7));
		m_recsList.add(new CRectangle(-4000,-18000,-2000,-5000,Layer.Metal1,8));
		m_recsList.add(new CRectangle(-4000,-6000,14000,-4500,Layer.Metal1,9));
								
		m_recsList.add(new CRectangle(-16000,8000,-6000,12000,Layer.P_diff,10));
		m_recsList.add(new CRectangle(6000,-12000,18500,6000,Layer.P_diff,11));
		
		m_recsList.add(new CRectangle(-16000,-12000,-6000,6000,Layer.N_diff,12));
		m_recsList.add(new CRectangle(6000,8000,18000,12500,Layer.N_diff,13));
																
		m_recsList.add(new CRectangle(-20000,-4000,20000,-1000,Layer.Poly,14));
		m_recsList.add(new CRectangle(-20000,-9000,20000,-7000,Layer.Poly,15));
																				
		m_recsList.add(new CRectangle(11500,9500,12500,10500,Layer.Contact,16));
		m_recsList.add(new CRectangle(12000,2000,13000,3000,Layer.Contact,17));
		m_recsList.add(new CRectangle(12500,-5500,13500,-5000,Layer.Contact,18));
		m_recsList.add(new CRectangle(12500,-11000,13000,-10500,Layer.Contact,19));
		m_recsList.add(new CRectangle(-11500,9500,-10500,10500,Layer.Contact,20));
		m_recsList.add(new CRectangle(-11500,1500,-10500,2500,Layer.Contact,21));
		m_recsList.add(new CRectangle(-13000,-10750,-12000,-10250,Layer.Contact,22));
																																		
		m_recsList.add(new CRectangle(-30000,0,40000,40000,Layer.Nwel,23));
		
		m_cifExporter.Export(m_recsList, file.getAbsolutePath());
	}
	
	// Members
	private LinkedList<CRectangle> m_recsList;
	private CIFImporter m_cifImporter;
	private CIFExporter m_cifExporter;
	
	public void testCIFImporter() 
	{
		m_cifImporter.Parse();
		
		m_cifExporter.Export(m_recsList, "execution/EvgeniTest1_Exported.cif");
	}

}
